class SceneManager {
	private static _instance: SceneManager;
	private root: eui.Component;//根场景
	private current: Scene;//需要显示的场景
	private pop: Scene;//弹出场景层
	private constructor() {
	}

	public static get instance() {
		if (this._instance == null) {
			this._instance = new SceneManager();
		}
		return this._instance;
	}

	public setRoot(root: eui.Component) {
		this.root = root;
	}

	public addScene(scene: Scene) {
		this.root.addChild(scene);
	}

	public removeScene(scene: Scene) {
		this.root.removeChild(scene);
		scene = null;
	}

	public removeSceneWithResult(scene: Scene, data: Object) {
		this.root.removeChild(scene);
		scene = null;
		if (this.root.numChildren > 1) {
			let topScene = this.root.getChildAt(this.root.numChildren - 1) as Scene;
			topScene.onGetResult(data);
		}
	}
}